﻿Imports Aricie.DNN.UI.Attributes
Imports DotNetNuke.UI.WebControls
Imports System.ComponentModel
Imports Aricie.DNN.UI.WebControls.EditControls

Namespace Aricie.DNN.Modules.LuceneSearch.Settings.AutoCompleteSettings

    <DefaultProperty("OrderingString")> _
    Public Class SortingField

        <LabelMode(LabelMode.None)> _
        <Editor(GetType(SelectorEditControl), GetType(EditControl))> _
        <Selector(GetType(AutoCompleteSettings.SortingFieldsSelector), "Id", "Id", True, False, "", "", False, False)> _
        Public Property FieldName As String = String.Empty

        Public Property IsDescending As Boolean = False

        Public Overrides Function ToString() As String
            Return String.Format("{1} {0}", IIf(IsDescending, "↓", "↑"), FieldName)
        End Function

        <Browsable(False)> _
        Public ReadOnly Property SearchString As String
            Get
                Return String.Format("{0}{1}", IIf(IsDescending, "-", String.Empty), FieldName)
            End Get
        End Property

        <Browsable(False)> _
        Public ReadOnly Property OrderingString As String
            Get
                Return ToString()
            End Get
        End Property

    End Class

End Namespace